/***********************************************************************
	filename: 	DaterOpCreater.cpp
	created:	18/4/2012
	author:		4Ys
	
	purpose:	Implements a class to handle the Tanslators.
*************************************************************************/

#include "DaterOpCreater.h"
#include "DaterTransDefault.h"
#include "DaterTransEvent.h"
#include "DaterTransSignUp.h"
#include "DaterTransLogin.h"
#include "DaterTransGroup.h"
#include "DaterTransUser.h"

namespace Dater
{
	//----------------------------------------------------------------------------//
	template<> OpCreater* Singleton<OpCreater>::ms_Singleton = 0;

	//----------------------------------------------------------------------------//
	OpCreater::OpCreater ()
	{
		_transNum = /*TRANSNUM*/0;

		_transVector.push_back(TransDefault::getSingletonPtr());
		_transNum++;

		_transVector.push_back(TransEventAdd::getSingletonPtr());
		_transNum++;

		_transVector.push_back(TransEventDelete::getSingletonPtr());
		_transNum++;

		_transVector.push_back(TransEventUpdate::getSingletonPtr());
		_transNum++;
		
		_transVector.push_back(TransEventView::getSingletonPtr());
		_transNum++;

		_transVector.push_back(TransLogin::getSingletonPtr());
		_transNum++;

		_transVector.push_back(TransSignUp::getSingletonPtr());
		_transNum++;
		
		_transVector.push_back(TransGroupCreate::getSingletonPtr());
		_transNum++;

		_transVector.push_back(TransGroupAddMember::getSingletonPtr());
		_transNum++;

		_transVector.push_back(TransGroupAskMember::getSingletonPtr());
		_transNum++;

		_transVector.push_back(TransGroupView::getSingletonPtr());
		_transNum++;

		_transVector.push_back(TransGroupJoin::getSingletonPtr());
		_transNum++;

		_transVector.push_back(TransGroupAskJoin::getSingletonPtr());
		_transNum++;

		_transVector.push_back(TransGroupPublishEvent::getSingletonPtr());
		_transNum++;

		_transVector.push_back(TransGroupResponseToEvent::getSingletonPtr());
		_transNum++;

		_transVector.push_back(TransGroupDeleteMember::getSingletonPtr());
		_transNum++;

		_transVector.push_back(TransGroupList::getSingletonPtr());
		_transNum++;

		_transVector.push_back(TransGroupSearch::getSingletonPtr());
		_transNum++;

		_transVector.push_back(TransUserSearch::getSingletonPtr());
		_transNum++;
		//
	}

	Translator* OpCreater::generate ( char* order )
	{
		for(int i = 1; i < _transNum; i++)
		{
			if(_transVector[i]->judge(order))
			{
				return _transVector[i];
			}
		}
		return _transVector[0];
	}
}